<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const value = {
            arr:[1,2,3],
            obj:{
                msg:'ok',
                list:['hello',['world','yes']],
                flag: true 
            }
        }


        function deepClone(value) {
            if(typeof value !== 'object' || value === null ){
                return value 
            }

            const res = Array.isArray(value) ? [] : {} 

            for(let key in value ){
                if(value.hasOwnProperty(key)){
                    res[key] = deepClone(value[key]) 
                }
               
            }

            return res  
        }

        console.log(deepClone(value));
    </script>
</body>
</html>